package com.lam.framework.init;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import com.lam.common.config.AppBaseConfig;
import com.lam.common.config.CommonConfig;
import com.lam.common.utils.IpUtils;

/**
 * @author lam
 *
 */
@Component
@Order(1)
public class ApplicationInitRunner implements ApplicationRunner {
	
	protected final Logger logger = LoggerFactory.getLogger(getClass());
	
	@Autowired
	protected AppBaseConfig appBaseConfig;
	@Autowired
	protected CommonConfig commonConfig;

	@Override
	public void run(ApplicationArguments args) throws Exception {
		
		logger.info("=================================================");
		logger.info(" 【{} {}】服务已启动!", appBaseConfig.getName(), appBaseConfig.getVersion());
		logger.info(" 访问地址: http://{}:{}/{}", IpUtils.getHostIp(), commonConfig.getPort(), commonConfig.getContextPath());
		logger.info("=================================================");
	}

}
